package com.guijq.selfcode.niolearn;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author yangjf
 * @time 2019-07-09 13:33
 */
public class TestJavaNIO {
    public void readNIO() {
        String pathname = "nio.txt";
        FileInputStream fin = null;
        try {
            fin = new FileInputStream(new File(pathname));
            FileChannel channel = fin.getChannel();
            int capacity = 100;
            ByteBuffer bf = ByteBuffer.allocate(capacity);
            System.out.println("限制是：" + bf.limit() + "容量是：" + bf.capacity()
                    + "位置是：" + bf.position());
            int length = -1;
//            while ((length == channel.read()))


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }
}
